package com.qingcheng.controller;

import com.alibaba.dubbo.config.annotation.Reference;
import com.qingcheng.service.goods.SkuService;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.CrossOrigin;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import javax.servlet.http.HttpServletResponse;

@RequestMapping("/sku")
@CrossOrigin  //跨域注解
@Controller
public class SkuController {

    @Reference
    private SkuService skuService;

    @RequestMapping("/findPrice")
    @ResponseBody
    public Integer findPrice(String skuId, HttpServletResponse response){

        //response.addHeader("access-control-allow-origin", "*");
        Integer price = skuService.findPrice(skuId);
        return price;
    }

    @RequestMapping("/importAll")
    @ResponseBody
    public boolean importAll() {
        boolean result = false;
        try {
            result = skuService.importAll();
        } catch (Exception e) {
            e.printStackTrace();
        }
        return result;
    }


}
